home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Automatic Kerning.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  1.8 KB  |  80 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void AutomaticKerning(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char            *myString = "WAVE AWAY.";
  39.     gxPoint            myPoint;
  40.     gxRunControls        gxRunControls;
  41.     gxShape            layout;
  42.     short            len, level = 0;
  43.     gxStyle            myStyle;
  44.     gxViewPort        aViewPort;
  45.     
  46.     /* Initialization */
  47.     
  48.     myPoint.x = ff(30);
  49.     myPoint.y = ff(50);
  50.     
  51.     aViewPort = GXNewWindowViewPort(sampleWindow);
  52.     SetDefaultViewPort(aViewPort);
  53.     
  54.     len = MyStrLen(myString);
  55.     InitializeRunControls(&gxRunControls);
  56.     
  57.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(60), 0, nil, nil, 0, nil);
  58.     
  59.     layout = GXNewLayout(
  60.         1, &len, (void *) &myString,
  61.         1, &len, &myStyle,
  62.         1, &len, &level,
  63.         nil, &myPoint);
  64.     GXDrawShape(layout);
  65.     
  66.     gxRunControls.kerningInhibitFactor = fract1 / 2;
  67.     GXSetStyleRunControls(myStyle, &gxRunControls);
  68.     GXMoveShape(layout, 0, ff(75));
  69.     GXDrawShape(layout);
  70.     
  71.     gxRunControls.kerningInhibitFactor = fract1;
  72.     GXSetStyleRunControls(myStyle, &gxRunControls);
  73.     GXMoveShape(layout, 0, ff(75));
  74.     GXDrawShape(layout);
  75.     
  76.     GXDisposeShape(layout);
  77.     GXDisposeStyle(myStyle);
  78.     GXDisposeViewPort(aViewPort);
  79.     }    /* main */
  80.